<!DOCTYPE html>

<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../../vue文件/vue.js"></script>
    

</head>
<body>
    <div id="app">
        <input type="button" value="开始" @click='start'>
        <input type="button" value="结束" @click='stop'>
        <h4 v-text='msg'></h4>
    </div>

</body>
<script>
    let vm = new Vue ({
        el:'#app',
        data:{
            msg:'好好学习,天天向上!',
            intervarID:null
            // 定义定时器
        },
        methods:{
            start(){

                that=this
                clearInterval(this.intervarID)

               this.intervarID =  setInterval(()=>{
                    var star = that.msg.substring(0,1)//截取
                    var end = that.msg.substring(1)
                    that.msg = end + star
                },500)
            },
            stop(){
                clearInterval(this.intervarID)
                this.intervarID=null
            }
        }
    })
</script>
</html>